xenstored: Fix socket-based connection teardown. Reading zero bytes
authorkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 25 Jul 2007 08:51:14 +0000 (09:51 +0100)
committerkfraser@localhost.localdomain <kfraser@localhost.localdomain>
Wed, 25 Jul 2007 08:51:14 +0000 (09:51 +0100)
*should* in fact cause the connection to be destroyed. Fix this with a
little extra code in the readfd() handler.
Signed-off-by: Keir Fraser <keir@xensource.com>
tools/xenstore/xenstored_core.c

index 1081103459e6495fe9662acaeb9db5c3b88a192a..f34a698cb4ac8668e5c4c6f2f2ab292733cc4166 100644 (file)
@@ -1368,6 +1368,12 @@ static int readfd(struct connection *conn, void *data, unsigned int len)
                        break;
        }
 
+       /* Reading zero length means we're done with this connection. */
+       if ((rc == 0) && (len != 0)) {
+               errno = EBADF;
+               rc = -1;
+       }
+
        return rc;
 }